home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 110 / EnigmaAmiga110CD.iso / dalla rivista / host contacted / wbstartup+.lha / WBStartup+ / Source / WBStartup+OS3.5 / ReadKeyboard.c < prev    next >
C/C++ Source or Header  |  2000-02-28  |  4KB  |  142 lines

  1. #include <exec/types.h>
  2. #include <exec/ports.h>
  3. #include <exec/io.h>
  4. #include <proto/exec.h>
  5. #include <devices/keyboard.h>
  6. #include <devices/inputevent.h>
  7. #include <devices/input.h>
  8.  
  9. #include "ReadKeyboard.h"
  10. #include "WBStartup+.h"
  11.  
  12. #include <proto/input.h>
  13. #include <clib/input_protos.h>
  14.  
  15. #include <clib/alib_protos.h>
  16. #include <stdio.h>
  17. #include <string.h>
  18.  
  19. #include <clib/utility_protos.h>
  20.  
  21.  
  22. extern struct Device *InputBase;
  23. //extern struct Library *UtilityBase;
  24.  
  25. /*
  26. BOOL IsQualifierDepressed(struct WBStartupPrefs *prefs)
  27. {
  28.   struct MsgPort *InputMP;
  29.   struct IOStdReq *InputIO;
  30.   UBYTE  matrix[13];
  31. //  ULONG inputsigflag;
  32.   BOOL success=FALSE;
  33.   BOOL runprefs=FALSE;
  34.  
  35.   /////////////////////////
  36.   // Set up input device //
  37.   /////////////////////////
  38.   if (InputMP=CreateMsgPort())
  39.   {
  40.     if (InputIO = CreateIORequest (InputMP, sizeof (struct IOStdReq)))
  41.     {
  42.       if ( !(OpenDevice("keyboard.device",0,(struct IORequest *) InputIO,0)) )
  43.       {
  44.         //inputsigflag = 1L << InputMP->mp_SigBit;
  45.  
  46.         InputIO->io_Length  = 13;
  47.         InputIO->io_Command = KBD_READMATRIX;
  48.         InputIO->io_Data = matrix;
  49.         DoIO ((struct IORequest *) InputIO);
  50.  
  51.         if((matrix[96/8] & (1<<(96%8))))  // 96 (is the Raw Key number for Left Shift, p. 831 RKM
  52.           success=TRUE;
  53.         else if((matrix[99/8] & (1<<(99%8))))  // 99 is the Raw Key number for Ctrl
  54.           runprefs=TRUE;
  55.         else if((matrix[100/8] & (1<<(100%8)))) // 100 is the Raw Key number for Left Alt
  56.           prefs->Interactive = TRUE;
  57.  
  58.         CloseDevice ((struct IORequest *) InputIO);
  59.       }
  60.       DeleteIORequest(InputIO);
  61.     }
  62.     DeleteMsgPort(InputMP);
  63.   }
  64.  
  65.   if (runprefs)
  66.     RunPrefs(prefs);
  67.   return(success);
  68. }
  69. */
  70.  
  71. //NEW
  72.  
  73. BOOL IsQualifierDepressed (struct WBStartupPrefs *prefs)
  74. {
  75.   struct IORequest *InputIO;
  76.   struct MsgPort *InputMP;
  77.   BOOL success = FALSE;
  78.   BOOL runprefs = FALSE;
  79.  
  80.   /////////////////////////
  81.   // Set up input device //
  82.   /////////////////////////
  83.  
  84.   if (InputMP = CreatePort (NULL, 0))
  85.     {
  86.       if (InputIO = CreateExtIO (InputMP, sizeof (struct IOStdReq)))
  87.         {
  88.           if (!OpenDevice ("input.device", 0, (struct IORequest *) InputIO, 0))
  89.            {
  90.               UWORD data;
  91.               //char buffer [6];
  92.  
  93.               InputBase = (struct Device *) InputIO -> io_Device;
  94.  
  95.               data = PeekQualifier();
  96.  
  97.               /*
  98.               sprintf (buffer, "%x", data);
  99.               ShowRequester (buffer);
  100.  
  101.               // check user input
  102.  
  103.               ShowRequester (prefs -> RunPrefsQual);
  104.               ShowRequester (prefs -> DisableQual);
  105.               ShowRequester (prefs -> InteractiveQual);
  106.               */
  107.  
  108.               if (data & (GetQualName (prefs -> RunPrefsQual)))
  109.                 {
  110.                   runprefs = TRUE;
  111.                 }
  112.               else if (data & (GetQualName (prefs -> DisableQual)))
  113.                 {
  114.                   success = TRUE;
  115.                 }
  116.               else if (data & (GetQualName (prefs -> InteractiveQual)))
  117.                 {
  118.                   prefs -> Interactive = TRUE;
  119.                 }
  120.  
  121.               CloseDevice ((struct IORequest *) InputIO);
  122.             }
  123.           else
  124.             ShowRequester ("failed to open input device");
  125.  
  126.           DeleteIORequest (InputIO);
  127.         }
  128.       else
  129.         ShowRequester ("Failed to create IORequest");
  130.  
  131.       DeleteMsgPort (InputMP);
  132.     }
  133.   else
  134.     ShowRequester ("failed to create msg port");
  135.  
  136.   if (runprefs)
  137.     RunPrefs (prefs);
  138.  
  139.   return(success);
  140. }
  141.  
  142.